package com.trippin.Utils;

import java.lang.reflect.Type;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;

public class TrippinDateJsonDeserializer implements JsonDeserializer<Date> {


	@Override
	public Date deserialize(JsonElement json, Type type,
			JsonDeserializationContext context) throws JsonParseException {
		
		String dateString = json.getAsString();
		dateString = dateString.trim();
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
		try {
			return sdf.parse(dateString);
		} catch (ParseException e) {
			throw new JsonParseException(e);
		}
	}

}
